#ifndef WIDGETMANAGE_H
#define WIDGETMANAGE_H

#include<QWidget>
#include<QMutex>
#include<QMutexLocker>
#include<QAtomicPointer>
#include<QHash>

#define WM WidgetManage::GetInstance()

class WidgetManage : public QWidget
{
    Q_OBJECT
public:
    static WidgetManage *GetInstance()
    {
       if(!instance)
        {
            if(!instance)
            {
                instance=new WidgetManage;
            }
       }
       return instance;
    }
    void  SetCurrentWidget(QWidget *);
    QWidget *GetCurrentWidget();
    void AddWidget(QString name,QWidget*);//
    QWidget *GetWidget(QString);//
private:
    WidgetManage();

    QHash <QString,QWidget*> widgets;//
    QWidget *pCurrentWidget;

    //sigleTon
    static QMutex mutex;
    static WidgetManage* instance;

    class QGarbo
    {
    public:
     ~QGarbo()
        {
            if(instance!=NULL)
            {
                delete instance;
            }
           //delete &widgets;
        }

     };
     static QGarbo garbo;
};
#endif // WIDGETMANAGE_H
